#ifndef __NET_PACKETCACHE__
#define __NET_PACKETCACHE__
#pragma once
#include "net_messages.h"
#include "../nodecache/nodecache.h"
#include <glib.h>

#define NET_MAX_PACKET_CACHE_LIFE_SEC	30
#define NET_PACKET_CACHE_CLEAR_TIME	3

typedef struct {
	node	*n;
	GTimeVal time;
} packet;

static GHashTable *packetcache;
pthread_mutex_t packetcache_mtx;
pthread_t packetcache_handler;

void packetcache_init();
#define lock_packetcache() 	pthread_mutex_lock(&packetcache_mtx)
#define unlock_packetcache() 	pthread_mutex_unlock(&packetcache_mtx)

void packetcache_add(char[NET_DESCRIPTOR_ID_LEN], node*);
node* packetcache_get(guint8	[NET_DESCRIPTOR_ID_LEN]);

#endif
